package com.itmumu.miniwechat.common.utils;


import com.itmumu.miniwechat.user.domain.po.User;

public class ContextUtil {

    private static final ThreadLocal<User> userInfoThreadLocal = new ThreadLocal<>();

    /**
     * 存储用户信息
     */
    public static void setUserInfo(User userInfo) {
        userInfoThreadLocal.set(userInfo);
    }

    /**
     * 获取用户信息
     */
    public static User getUserInfo() {
        return userInfoThreadLocal.get();
    }

    /**
     * 清除用户信息
     */
    public static void clear() {
        userInfoThreadLocal.remove();
    }
}
